String concat
Course- Java >
The java string concat() method combines specified string at the end of this string. It returns combined string. It is like appending another string.
Signature
The signature of string concat() method is given below:
- public String concat(String anotherString)
Parameter
anotherString : another string i.e. to be combined at the end of this string.
Returns
combined string
Java String concat() method example
- public class ConcatExample{
- public static void main(String args[]){
- String s1="java string";
- s1.concat("is immutable");
- System.out.println(s1);
- s1=s1.concat(" is immutable so assign it explicitly");
- System.out.println(s1);
- }}
java string java string is immutable so assign it explicitly